package com.chuanyang.driverh.mainother.adapter;


import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.chuanyang.driverh.utils.BitmapUtil;
import com.chuanyang.driverh.utils.widget.photoview.PhotoView;

import java.util.List;

public class LookPicAdapter extends PagerAdapter {
    private List<String> images;
    private Context context;

    public LookPicAdapter(Context context, List<String> images) {
        this.context = context;
        this.images = images;
    }


    @Override
    public int getCount() {
        return images.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        PhotoView photoView = new PhotoView(context);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
         photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
        photoView.setLayoutParams(layoutParams);
//        BitmapUtil.showImgForNetPath(images.get(position), photoView);
        BitmapUtil.showLocalImg(images.get(position),photoView);

        container.addView(photoView);
        return photoView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
//		super.destroyItem(container, position, object);
        container.removeView((View) object);
    }
}
